Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[State Sync] Add server side implementation of semi-intelligent syncing mode. #5742

Merged
merged 1 commit into from
Dec 6, 2022

Conversation

JoshLind
Copy link
Contributor

@JoshLind JoshLind commented Dec 1, 2022

Note: most of this PR is just boilerplate and tests. There's probably only 30 lines of interesting code.

Description

This PR adds the server side implementation of a new "semi-intelligent" state syncing mode, where the client (syncing node) requests chunks of transactions or outputs from a peer, and the peer decides which data to return based on whichever is quicker: (i) downloading and applying the outputs; or (ii) downloading and executing the transactions. The trade-off is that outputs are quick to apply (but might require lots of network data), and transactions are slow to execute (but might require much less network data).

The way the storage server on the peer decides which data to send per chunk is through a simple value provided by the client on the request (max_num_output_reductions), which tells the server that if it needs to reduce the number of outputs being requested more than max_num_output_reductions times, it should just return transactions. For example: a client requests 2000 outputs in a single chunk and specifies max_num_output_reductions = 2. The server will attempt to serve this data, and if it needs to reduce the outputs (halve them) more than 2 times (i.e., send less than 500 outputs) it will instead fallback to sending transactions for the chunk.

Some notes:

  • max_num_output_reductions is configurable so that we can tune it. The current default is 2.
  • This change is backward compatible because client requests and responses are simple enums, and we append two new types to each, so serialization should be backward compatible. Will also confirm (manually) that serialization can handle this.

Test Plan

New and existing tests!

@@ -1244,6 +1321,63 @@ impl StorageReaderInterface for StorageReader {
)))
}

fn get_transactions_or_outputs_with_proof(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: this is the new logic. Everything else is boilerplate to handle the new request types 😄

Copy link
Contributor

@bchocho bchocho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a couple questions

// doesn't fit, return a transaction chunk instead.
let mut num_output_reductions = 0;
while num_output_reductions <= max_num_output_reductions {
let output_list_with_proof = self
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any concern calling this multiple times will be expensive?

Copy link
Contributor Author

@JoshLind JoshLind Dec 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we're currently doing this for all storage calls where the data overflows the max frame size. At worst, I've seen it take a couple seconds (<= 2). There is a task on the storage side to provide better APIs so we don't have to call in like this. Once those land, we can migrate.

} else if num_outputs_to_fetch == 1 {
break; // We cannot return less than a single item. Fallback to transactions
} else {
increment_network_frame_overflow(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will mean there can be more overflows than responses (because multiple overflows per response). Is this the intention?

Copy link
Contributor Author

@JoshLind JoshLind Dec 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is fine. We have other metrics to track the number (and types) of requests and responses, so using this we can calculate the average number of overflows/retries per request. Does that make sense?

@JoshLind JoshLind enabled auto-merge (rebase) December 6, 2022 13:26
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 6, 2022

✅ Forge suite land_blocking success on c72d40ea44325482010ad348bd9b116cbf8d0b0c

performance benchmark with full nodes : 6929 TPS, 5715 ms latency, 7800 ms p99 latency,(!) expired 600 out of 2959440 txns
Test Ok

@github-actions
Copy link
Contributor

github-actions bot commented Dec 6, 2022

✅ Forge suite compat success on testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> c72d40ea44325482010ad348bd9b116cbf8d0b0c

Compatibility test results for testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> c72d40ea44325482010ad348bd9b116cbf8d0b0c (PR)
1. Check liveness of validators at old version: testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b
compatibility::simple-validator-upgrade::liveness-check : 7224 TPS, 5283 ms latency, 8400 ms p99 latency,no expired txns
2. Upgrading first Validator to new version: c72d40ea44325482010ad348bd9b116cbf8d0b0c
compatibility::simple-validator-upgrade::single-validator-upgrade : 4484 TPS, 9095 ms latency, 12400 ms p99 latency,no expired txns
3. Upgrading rest of first batch to new version: c72d40ea44325482010ad348bd9b116cbf8d0b0c
compatibility::simple-validator-upgrade::half-validator-upgrade : 4706 TPS, 8626 ms latency, 10300 ms p99 latency,no expired txns
4. upgrading second batch to new version: c72d40ea44325482010ad348bd9b116cbf8d0b0c
compatibility::simple-validator-upgrade::rest-validator-upgrade : 6970 TPS, 5520 ms latency, 9800 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> c72d40ea44325482010ad348bd9b116cbf8d0b0c passed
Test Ok

@JoshLind JoshLind merged commit 76e743c into main Dec 6, 2022
@JoshLind JoshLind deleted the ss_new_mode_3 branch December 6, 2022 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants